package roborally.itemsonboard;

import roborally.board.Board;
import roborally.supporting.Position;

/**
 * This class represents a wall. This is an object on the board which cannot move, and can contain no 
 * other object on the same position.
 * 
 * 
 * @author Molderez Tom, 2de bach Ingenieurswetenschappen Computerwetenschappen-Elektrotechniek and Reniers Jorn, 2de bach Ingenieurswetenschappen Werktuigkunde-Computerwetenschappen
 * @version 2.0
 */
public class Wall extends BoardItemImpl {
	
//Constructors ----------------------------------------------------------------------------------------------------------	
	
	/**
	 * Creates a new wall at the given position and at the given board.
	 * 
	 * @param board The board at which this will should be.
	 * @param position The position at which this wall should be.
	 * @effect 
	 * 		| super(board, position)
	 * @throws IllegalArgumentException
	 * 		Position is null or the board can't have this new PositionItem.
	 * 		| position== null || ( board != null && !board.canHaveAsItem(new this) )
	 */
	public Wall(Board board, Position position){
		super(board, position);
	}
	
	/**
	 * Creates a new wall at (0,0), which has no board.
	 * 
	 * @effect 
	 * 		| this(null, Position.Origin)
	 */
	public Wall(){
		this(null, Position.ORIGIN);
	}
	
//Position ----------------------------------------------------------------------------------------------------------	
	
	/**
	 * Controls if a given positionItem can be on the same position as this.
	 * 
	 * @param positionItem The positionItem to be controlled
	 * @return False if positionItem is null.
	 * 		| if positionItem == null
	 * 		|	then result == false
	 * @return True if positionItem is a wall and is this.
	 * 		| if Robot.class.isInstance(positionItem)
	 *		|	then result == (positionItem == this)
	 * @return False if positionItem is a Robot.
	 * 		| if Robot.class.isInstance(positionItem)
	 *		|	then result == false
	 * @return False if positionItem is a battery.
	 * 		| if Battery.class.isInstance(positionItem)
	 *		|	then result == false
	 * @return When another type of positionItem is created, in the future, he is responsible for handling this.
	 * 		| result == positionItem.canHaveItemOnSamePosition(this)
	 */
	@Override
	public boolean canHaveItemOnSamePosition(BoardItem positionItem) {
		if(positionItem == null)
			return false;
		if(Wall.class.isInstance(positionItem))
			return positionItem == this ;
		else if(Robot.class.isInstance(positionItem))
			return false;
		else if(Battery.class.isInstance(positionItem))
			return false;
		else
			return positionItem.canHaveItemOnSamePosition(this);
		
	}

//Shoot ----------------------------------------------------------------------------------------------------------
	
	/**
	 * When this is been hit, nothing happens.
	 */
	@Override
	public void beenShot() {		
	}
}
